home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre1.z / postgre1 / test / postfs.usr.bin / rmdir.c < prev   
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.0 KB  |  63 lines

  1. /*
  2.  * Copyright (c) 1983 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef lint
  8. char copyright[] =
  9. "@(#) Copyright (c) 1983 Regents of the University of California.\n\
  10.  All rights reserved.\n";
  11. #endif not lint
  12.  
  13.  
  14. /*
  15.  * Remove directory
  16.  */
  17. #include <stdio.h>
  18. #include "tmp/libpq-fs.h"
  19.  
  20. extern char *getenv();
  21.  
  22. main(argc,argv)
  23.     int argc;
  24.     char **argv;
  25. {
  26.     int errors = 0;
  27.     char *dbname;
  28.  
  29.     if ((dbname = getenv("DATABASE")) == (char *) NULL) {
  30.         fprintf(stderr, "no database specified in env var DATABASE\n");
  31.         fflush(stderr);
  32.         exit (1);
  33.     }
  34.  
  35.     PQsetdb(dbname);
  36.  
  37.     (void) PQexec("begin");
  38.  
  39.     if (argc < 2) {
  40.         fprintf(stderr, "usage: %s directory ...\n", argv[0]);
  41.         PQfinish();
  42.         exit(1);
  43.     }
  44.  
  45.     while (--argc) {
  46.         if (p_rmdir(*++argv) < 0) {
  47.             fprintf(stderr, "p_rmdir: ");
  48.             perror(*argv);;
  49.             errors++;
  50.         }
  51.     }
  52.  
  53.     if (errors == 0)
  54.         (void) PQexec("end");
  55.     else
  56.         (void) PQexec("abort");
  57.  
  58.     PQfinish();
  59.  
  60.     exit(errors != 0);
  61.     /* NOTREACHED */
  62. }
  63.